﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRasta.Configuration;
using uREST.Core.Services;
using uREST.Core.Resources;
using uREST.Blog.Resources;
using uREST.Core;
using uREST.Blog.Handlers;
using uREST.Core.Codecs;
using OpenRasta.Web;

namespace uREST.Blog.Services
{
    public class BlogService : IuRESTService
    {
        public EndPoint EndPoint
        {
            get 
            {
                return new EndPoint
                {
                    Name = "Blog Service",
                    Description = "",
                    Href = typeof(List<Resources.Blog>).CreateUri("BlogList").ToString()
                };
            }
        }

        public void RegisterHandlers()
        {
            ResourceSpace.Has.ResourcesOfType<List<Resources.Blog>>()
                .AtUri(uRESTConfig.BaseUrl + "/blogs").Named("BlogList")
                .HandledBy<BlogHandler>()
                .TranscodedBy<JsonNetCodec>();

            ResourceSpace.Has.ResourcesOfType<Resources.Blog>()
                .AtUri(uRESTConfig.BaseUrl + "/blogs/{id}").Named("Blog")
                .HandledBy<BlogHandler>()
                .TranscodedBy<JsonNetCodec>();
        }
    }
}
